<?php
if($_POST['post_title']){
    require('wp-blog-header.php');
    $cat = $_POST['post_category'];
    
    $tag = explode(",", $_POST['tags_input']);
    $my_post = array();
    $my_post['post_title'] = $_POST['post_title'];
    $my_post['post_content'] = $_POST['post_content'];
    $my_post['post_status'] = 'publish';
    $my_post['post_author'] = 1;
    $my_post['tags_input'] = $tag;
    $my_post['post_category'] = $_POST['post_category'];

    $thumbNail = file_get_contents('http://clip102.com/thumb.php?src='.$_POST['thumbnail'].'&bot=2');
    #print_r($my_post);
    $post = post($my_post);
    if(strlen($thumbNail) > 10){
        update_post_meta($post, 'Image', $thumbNail);
    }
    echo $post;
    #echo '<br><a href="caovang.com">Back</a>';
    die();
}
function post($my_post){
    // Create post object
    /*
    $my_post = array();
    $my_post['post_title'] = 'My post';
    $my_post['post_content'] = 'This is my post.';
    $my_post['post_status'] = 'publish';
    $my_post['post_author'] = 1;
    $my_post['tags_input'] = array('tag 1', 'tag 2');
    $my_post['post_category'] = array(1);
       */
    // Insert the post into the database
    return wp_insert_post( $my_post );
}
/*
$post = array(
  'ID' => [ <post id> ] //Are you updating an existing post?
  'menu_order' => [ <order> ] //If new post is a page, sets the order should it appear in the tabs.
  'comment_status' => [ 'closed' | 'open' ] // 'closed' means no comments.
  'ping_status' => [ 'closed' | 'open' ] // 'closed' means pingbacks or trackbacks turned off
  'pinged' => [ ? ] //?
  'post_author' => [ <user ID> ] //The user ID number of the author.
  'post_category' => [ array(<category id>, <...>) ] //Add some categories.
  'post_content' => [ <the text of the post> ] //The full text of the post.
  'post_date' => [ Y-m-d H:i:s ] //The time post was made.
  'post_date_gmt' => [ Y-m-d H:i:s ] //The time post was made, in GMT.
  'post_excerpt' => [ <an excerpt> ] //For all your post excerpt needs.
  'post_name' => [ <the name> ] // The name (slug) for your post
  'post_parent' => [ <post ID> ] //Sets the parent of the new post.
  'post_password' => [ ? ] //password for post?
  'post_status' => [ 'draft' | 'publish' | 'pending' ] //Set the status of the new post. 
  'post_title' => [ <the title> ] //The title of your post.
  'post_type' => [ 'post' | 'page' ] //Sometimes you want to post a page.
  'tags_input' => [ '<tag>, <tag>, <...>' ] //For tags.
  'to_ping' => [ ? ] //?
);  

<tag>, <...>' ] //For tags.
  'to_ping' => [ ? ] //?
);  

*/